#include "./../Include/public.h"
#include<errno.h>
void stu_input_file()//输入数据时，无选课 
{
	FILE *fp ;
	struct stu* p=head_stu;
	
	fp = fopen("./data/stu.txt","r");
	if(fp == NULL){
		printf("%s", strerror(errno));
		return;
	}
	
	while (!feof(fp)) {     //判断文件是否结尾 
		struct stu* node = (struct stu*)malloc(sizeof(struct stu));
		fscanf(fp, "%s %s %d",node->sno,node->name,&node->courses[0]);
		for (int i=1;i<=node->courses[0];i++) {
			fscanf(fp, "%d",&node->courses[i]);
		}
		fscanf(fp,"%d",&node->sum);
		if (p == NULL) {
			head_stu = node;
			p = node;
		} else {
			p->next = node;
			p = node;
		}
	}
	
	p->next = NULL;
	//处理最后的情况
	p = head_stu;
	while (p->next->next != NULL) {
		p = p->next;
	} 
	p->next = NULL;
	fclose(fp); 

}
